package cate.game.play.skill.brother;

import cate.common.table.d.GD;
import cate.common.table.d.GDSkill;
import cate.common.util.XT;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import easy.java.dev.note.NoteField;

import java.util.List;

public class HeroNumBS extends BrotherSkillSelector {

	@NoteField("范围")
	private byte scope;

	@NoteField("检测操作")
	private byte compare;

	@NoteField("人数")
	private int num;

	//范围=0&人数=3&检测操作=4
	@Override
	protected void parseArgs(PlayCfgArgs args) {
		scope = args.getByte("范围", GDSkill.Scope.ENEMY);
		compare = args.getByte("检测操作", GD.Compare.EQ);
		num = args.getInt("人数", 1);
	}

	@Override
	public boolean check(SkillActionCtx action) {
		List<Fighter> fighters = TargetSelector.findByScope(action.getTeamVs(), action.getActor(), scope);
		if (XT.isBlank(fighters)) {
			return false;
		}
		int heroNum = fighters.size();
		return GD.Compare.calc(compare, heroNum, num);
	}
}
